﻿using System;
using CPETwit.Web.Service.Interface;
using CPETwit.Web.Business;
using CPETwit.Data.Entity;

namespace CPETwit.Web.Service.Implementation
{
    public class AuthentificationService : IAuthentificationService
    {
        AuthentificationBusiness GlobalAuthentificationBusiness;

        #region IAuthentificationService Members

        public bool CheckLoginAndPassword(string login, string password)
        {
            AuthentificationBusiness authentificationBusiness = this.getAuthentificationBusiness();
            return authentificationBusiness.CheckLoginAndPassword(login, password);
            
        }

        public bool SendMessageByMailForPassword(string email)
        {
            //throw new NotImplementedException();
            return true;
        }

        public User Test()
        {
            return null;
        }

        #endregion

        /// <summary>
        /// Retourne le business utilisateur instancié
        /// </summary>
        /// <returns></returns>
        private AuthentificationBusiness getAuthentificationBusiness()
        {
            if (this.GlobalAuthentificationBusiness == null)
            {
                this.GlobalAuthentificationBusiness = new AuthentificationBusiness();
            }
            return this.GlobalAuthentificationBusiness;
        }
    }
}
